package com.burpee.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.burpee.service.BoardService;
import com.burpee.ui.Board;

@Controller
@RequestMapping("/main.spring")
public class MainController {

	@Autowired
	BoardService boardService;
	
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView main(HttpServletRequest request, 
			HttpServletResponse response) {
		
		ModelAndView modelAndView = new ModelAndView();
		
		List<Board> boardList = boardService.list();
		
		modelAndView.addObject("boardList", boardList);
		
		modelAndView.setViewName("main");
		
		return modelAndView;
	}
}
